package com.depot.fastReport.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import com.soar.context.Environment;
import com.soar.jdbc.dbhelper.DbParameter;
import com.soar.jdbc.dbhelper.DbTemplates;
import com.soar.jdbc.dbhelper.SameTypes;
import com.soar.jdbc.dbhelper.SqlTypes;
import com.soar.jdbc.dbhelper.WhereTypes;

/**
 * 
 * @author zhangaoxiang
 * @version $Revision$ - $Author$ at $Date$
 * @description com.depot.fastReport.dao.FastReportDao
 */
public class FastReportDao
{
	
	/**
	 * 根据查记录单编号查询查验记录单信息
	 * @param env
	 * @param guid
	 * @return
	 * @throws SQLException
	 */
	public static HashMap<String,String> selectRecordInfoByEntryId(Environment env,String entryId) throws SQLException
	{
		DbParameter param = new DbParameter("ENTRY_HEAD t");
		param.setSelectFields("t.*,TO_CHAR(t.I_E_DATE, 'YYYY-MM-DD') F_I_E_DATE,TO_CHAR(t.D_DATE, 'YYYY-MM-DD') F_D_DATE");
		param.setWhereParams("t.ENTRY_ID",entryId, SqlTypes.VARCHAR, WhereTypes.NOT, SameTypes.YES);
		List<HashMap<String,String>> list = DbTemplates.select(env.getConnection(), param);
		if(list.size()>0)
		{
			return list.get(0);
		}
		else
		{
			return null;
		}
	}
	
	/**
	 * 根据查验记录单编号查询查验记录单货物列表
	 * 
	 * @param env
	 * @param domain
	 * @return
	 * @throws Exception
	 * */
	public static List<HashMap<String, String>> selectRecordGoods(Environment env, String entryId) throws SQLException
	{
		DbParameter param = new DbParameter("ENTRY_LIST");
		param.setWhereParams("ENTRY_ID",entryId, SqlTypes.VARCHAR, WhereTypes.NOT, SameTypes.YES);
		return DbTemplates.select(env.getConnection(), param);
	}
	
	/**
	 * 根据查验联系单编号查询查验联系单信息
	 * 
	 * @param env
	 * @param domain
	 * @return
	 * @throws Exception
	 * */
	public static HashMap<String,String> selectContactInfoByGuid(Environment env, String guid) throws SQLException
	{
		DbParameter param = new DbParameter("HG_CHECK_NOTICE");
		param.setWhereParams("GUID",guid, SqlTypes.VARCHAR, WhereTypes.NOT, SameTypes.YES);
		List<HashMap<String,String>> list = DbTemplates.select(env.getConnection(), param);
		if(list.size()>0)
		{
			return list.get(0);
		}
		else
		{
			return null;
		}
	}
	
	/**
	 * 根据查验联系单编号查询箱号信息
	 * 
	 * @param env
	 * @param domain
	 * @return
	 * @throws Exception
	 * */
	public static List<HashMap<String, String>> selectContactBoxs(Environment env, String guid) throws SQLException
	{
		DbParameter param = new DbParameter("HG_CHECK_BOX");
		param.setWhereParams("CHECK_BILL_NO",guid, SqlTypes.VARCHAR, WhereTypes.NOT, SameTypes.YES);
		return DbTemplates.select(env.getConnection(), param);
	}
}
